home *** CD-ROM | disk | FTP | other *** search
- #include <condefs.h>
- #include <fstream.h>
- #include <conio.h>
-
- #pragma hdrstop
-
- int main(int, char **)
- {
- char buff[81];
- cout << "Creating File..." << endl;
- ofstream outfile("test.dat");
- if (!outfile) return 0;
- cout << "Writing File..." << endl;
- for (int i=0;i<10;i++) {
- outfile << "This is line #" << (i + 1) << endl;
- }
- outfile.close();
- cout << "Opening File for Input..." << endl;
- ifstream infile("test.dat");
- if (!infile) return 0;
- cout << "Reading File..." << endl << endl;
- while (!infile.eof()) {
- infile.getline(buff, sizeof(buff));
- cout << buff << endl;
- }
- infile.close();
- cout << endl << "Press any key to continue...";
- getch();
- return 0;
- }
-
-